package so.shanku.essential.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.tsz.afinal.annotation.view.ViewInject;
import so.shanku.essential.R;
import so.shanku.essential.activity.base.BaseUIActivity;
import so.shanku.essential.utils.Utils;

/**
 * Created by Administrator on 2015/9/15.
 */
public  class UserChangeMainActivity extends BaseUIActivity {
	/**
	 * 更换手机
	 */
	@ViewInject(id= R.id.tv_changephone)
	private TextView tv_changephone;
	/**
	 * 更换密码
	 */
	@ViewInject(id = R.id.linear_change_password, click = "change_password_click")
	private LinearLayout linear_change_password;
	/**
	 * 更换手机
	 */
	@ViewInject(id = R.id.linear_change_phone, click = "change_phone_click")
	private LinearLayout linear_change_phone;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_user_change_main);
		String userPhone=Utils.getUserPhone(this);

		if(TextUtils.isEmpty(userPhone)){
			linear_change_password.setVisibility(View.GONE);
		} else {
			linear_change_password.setVisibility(View.VISIBLE);
		}
		setCenter_title( R.string.my_security_center);
		judgeIdBind();
	}

	@Override
	protected void onRestart() {
		super.onRestart();
		String userPhone=Utils.getUserPhone(this);

		if(TextUtils.isEmpty(userPhone)){
			linear_change_password.setVisibility(View.GONE);
		} else {
			linear_change_password.setVisibility(View.VISIBLE);
		}
		if(TextUtils.isEmpty(userPhone)){
			linear_change_password.setVisibility(View.GONE);
		} else {
			linear_change_password.setVisibility(View.VISIBLE);
		}
	}

	public void change_password_click(View view) {
		jumpTo(UserChangePasswordActivity.class);
	}

	public void change_phone_click(View view) {
		if (TextUtils.isEmpty(Utils.getUserPhone(this))) {
			jumpTo(UserChangePhoneSecondActivity.class);
		} else {
			jumpTo(UserChangePhoneFristActivity.class);
		}

	}
	public void judgeIdBind(){
		if(TextUtils.isEmpty(Utils.getUserPhone(this))){
			tv_changephone.setText(R.string.bind_phone);
		}
		else{
			tv_changephone.setText(R.string.change_phone);
		}
	}
}